#include "user_threads.h"

#include <stdio.h>

#define LOOPS 10
#define FIB 34

static int fibonaci(unsigned int n)
{
	if (n < 2) {
		return n;
	}
	return fibonaci(n-2) + fibonaci(n-1);
}

int thread0(void * arg)
{
    int i;
    for (i = 0; i < LOOPS; ++i) {
        printf("uthread #%d\n", uthread_self());
	fibonaci(FIB);
    }
    uthread_join(1, NULL);
    return 0;
}

int thread1(void * arg)
{
    int i;
    for (i = 0; i < LOOPS*2; ++i) {
        printf("uthread #%d\n", uthread_self());
	fibonaci(FIB);
    }
    return 0;
}

int main(int argc, char ** argv)
{
    uthread_init();
    uthread_create(&thread1, NULL, UTHREAD_MIN_PRIO);
    thread0(NULL);
    return 0;
}
